package com.crape.account.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.crape.account.dao.IDarrenAuditDAO;
import com.crape.common.exceptions.DAOException;
import com.crape.common.ibatis.SqlMapClientDaoSupportEx;
import com.crape.common.model.DarrenAudit;

public class DarrenAuditDAOImpl extends SqlMapClientDaoSupportEx implements IDarrenAuditDAO {

    @SuppressWarnings("unchecked")
    @Override
    public List<DarrenAudit> getDarrenAudits(DarrenAudit darrenAudit) throws DAOException {
        if (darrenAudit == null) {
            return null;
        }
        return (List<DarrenAudit>) this.queryList("getDarrenAudits", darrenAudit);
    }
    
    @SuppressWarnings("unchecked")
    @Override
    public List<DarrenAudit> getPagedDarrenAudits(Long accountid, String email, Integer status, Integer startIndex, Integer pageSize) throws DAOException {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountid", accountid);
        params.put("email", email);
        params.put("status", status);
        params.put("startIndex", startIndex);
        params.put("pageSize", pageSize);
        return (List<DarrenAudit>) this.queryList("getPagedDarrenAudits", params);
    }

    @Override
    public Long countDarrenAudits(Long accountid, String email, Integer status) throws DAOException {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountid", accountid);
        params.put("email", email);
        params.put("status", status);
        return (Long) this.queryObject("countDarrenAudits", params);
    }

    @Override
    public void insertDarrenAudit(DarrenAudit darrenAudit) throws DAOException {
        if (darrenAudit == null) {
            return;
        }
        this.insert("insertDarrenAudit", darrenAudit);
    }

    @Override
    public void updateDarrenAudit(DarrenAudit darrenAudit) throws DAOException {
        if (darrenAudit == null) {
            return;
        }
        this.update("updateDarrenAudit", darrenAudit);
    }

    @Override
    public void updateDarrenAuditStatus(Long accountid, Integer status) throws DAOException {
        if (accountid == null || status == null) {
            return;
        }
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountid", accountid);
        params.put("status", status);
        this.update("updateDarrenAuditStatus", params);
    }
}
